
<div style="margin:10px" >
    <h1>Create new customer</h1>
    
    <div id="form_create" class="div_form" >
        <p id="status1" style="font-size: 18px; color: red;"></p>
        <form class="form" >
            <table>
                <tr>
                    <td>
                        Customer name(*):
                    </td>
                    <td>
                        <input type="text" id="c_name" class="input_form" value="<?=$row['namecustomer']?>"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Detail(*):
                    </td>
                    <td>
                        <textarea id="c_detail" class="text_area" ><?=$row['details']?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        Address(*):
                    </td>
                    <td>
                        <input type="text" id="c_address" class="input_form" value="<?=$row['address']?>"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Phone(*):
                    </td>
                    <td>
                        <input type="text" id="c_phone" class="input_form" value="<?=$row['phone']?>"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Service Agreement(*):
                    </td>
                    <td>
                        <textarea id="c_service" class="text_area"><?=$row['service_agreement']?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>
                        IT service using:
                    </td>
                    <td>
                        <select id="service">
                            <option value="0" <?=$s=(($row['service_status']==0)?'selected':'')?>>No</option>
                            <option value="1" <?=$s=(($row['service_status']==1)?'selected':'')?>>Yes</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        Sale of equipment:
                    </td>
                    <td>
                        <select id="equipment">
                            <option value="0" <?=$s=(($row['project_status']==0)?'selected':'')?>>No</option>
                            <option value="1" <?=$s=(($row['project_status']==1)?'selected':'')?>>Yes</option>
                        </select>
                    </td>
                </tr>
                
                
                
            </table>
            <p style="margin-left: 140px"><input type="button" value="Update" onclick="Update()"> <br/></p>
            <div id="sending" style="margin-left: 20px;">
            <img src="../images/loading.gif" id="loading">
            </div>
        </form>
    </div>
    
    
</div>
<script>
$(document).ready(function() {
    $('#sending').hide();
});  

function reset(){
    $('#c_name').val('');
    $('#c_detail').val('');
    $('#c_address').val('');
    $('#c_phone').val('');
    $('#c_service').val('');
}
function Update(){

    var c_name=$('#c_name').val();
    var idcustomer=<?=$row['idcustomers']?>;
    //alert(dichvu);
    var c_detail=$('#c_detail').val();
    
    var c_address=$('#c_address').val();
    var c_phone=$('#c_phone').val();
    var c_service=$('#c_service').val();
    var service=$('#service').val();
    var equipment=$('#equipment').val();
    //alert(c_name);
    if((c_name=="")||(c_detail=="")||(c_address=="")||(c_phone=="")||(c_service=="")){ 
        $('#status1').html("Please fill in the field require (*)");
    }else{
        //if(confirm('Bạn đã kiểm tra kỹ nội dung rồi chứ?')){
        $('#sending').show();
        //$('#send').hide();
        
        $.ajax({
          url: '<?=WEBSITE_URL?>/ajax.php',
          data: { m: 'manage_customer', a:'update',c_name:c_name, c_detail:c_detail, c_address:c_address, 
              c_phone:c_phone,c_service:c_service, service:service, equipment:equipment,idcustomer:idcustomer},
          dataType:'json',
          success: function(data) {
            if (!data.success) {
                $("#status1").html('Update customer success');
               //alert(data.error);
               return false;

            }else{
                //$('#noidung_tin').html('Đã lưu');
                $("#status1").html('Update success');
                $('#sending').hide();
                //$('#send').hide();
                
            }
            //Update info
          } 
         
        });
        
    }

}
</script>
<style>
    table{

        margin: 10px;
        
    }
td
{
padding:3px;

}
</style>